package API.Collection.Set.TreeSet;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        Set<Integer> set = new TreeSet<>();
        set.add(5);
        set.add(3);
        set.add(1);
        set.add(2);
        set.add(4);
        for (Integer i : set) {
            System.out.print(i + " ");
        }
        System.out.println();
        set.forEach((integer) -> {
            System.out.print(integer + " ");
        });
        System.out.println();
        Iterator<Integer> iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.print(iterator.next() + " ");
        }
    }
}
